package com.harvest.scientific.ladder.pop;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.harvest.scientific.ladder.R;
import com.harvest.scientific.ladder.pop.basepopup.BasePopupWindow;

public class EmailPopupWindow extends BasePopupWindow implements View.OnClickListener {

    private TextView gmailTv;
    private TextView hotmailTv;
    private TextView yahooTv;

    private OnSelectListener onSelectListener;

    public EmailPopupWindow(Context context) {
        super(context);
        setContentView(R.layout.pop_email);
        gmailTv = findViewById(R.id.gmailTv);
        hotmailTv = findViewById(R.id.hotmailTv);
        yahooTv = findViewById(R.id.yahooTv);
        gmailTv.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.gmailTv)  {
            if (onSelectListener != null) {
                onSelectListener.onClicked("gmail.com");
            }
        } else if (v.getId() == R.id.hotmailTv) {
            if (onSelectListener != null) {
                onSelectListener.onClicked("hotmail.com");
            }
        } else if (v.getId() == R.id.yahooTv) {
            if (onSelectListener != null) {
                onSelectListener.onClicked("yahoo.com");
            }
        }
    }

    public EmailPopupWindow setOnSelectListener(OnSelectListener listener) {
        this.onSelectListener = listener;
        return this;
    }

    public interface OnSelectListener {
        void onClicked(String selected);
    }
}
